package utils

import (
	"encoding/json"
)

// StructToMap struct转map
func StructToMap(s interface{}) (map[string]interface{}, error) {
	jsonData, err := json.Marshal(s)
	if err != nil {
		return nil, err
	}

	var m map[string]interface{}
	err = json.Unmarshal(jsonData, &m)
	if err != nil {
		return nil, err
	}

	return m, nil
}
